const mongoose = require('./db')

// 课程表
const courseSchame = new mongoose.Schema({
    publisher : String, // 发布者
    title: {
        type: String,
        require: true,//必填
    }, //课程标题
    courseDesc: String,//课程描述
    language: String, //语言
    slill: String, // 技术水平
    chapters: [
        {
            type: mongoose.Schema.Types.ObjectId,
            ref: 'chapter'
        }
    ], // 章节
    price: String, //价格
    type: String, // 分类
    img: String,  // 课程封面
    follow: Array // 存储学习学生的id
})

const courseModel = mongoose.model('course', courseSchame, 'course')

const chapterSchame = new mongoose.Schema({
    name: String,//章节标题
    videoUrl: String,//视频链接
})
const chapterModel = mongoose.model('chapter', chapterSchame, 'chapter')

module.exports = { courseModel, chapterModel }
